<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Task Session</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h3>Task Session</h3>
        Make sure your browser accept cookies. <br>
        Task can be created and loaded automatically.<br>
        <p>
        <%
        #set task id
        if(is.null(COOKIES$"task")){
        taskid <- format(Sys.time(), "%y%m%d%H%M%S")
        filepath <- file.path("/var/www/Rcloud/upload", taskid)
        dir.create(filepath)
        setCookie("task", taskid)
        save(taskid, file=paste(filepath, "/", taskid, ".rda", sep=""))
        cat(paste("A new task created. (id:", taskid, ")"))
        }else{
        taskid <- unlist(strsplit(COOKIES$"task", "|", fixed=TRUE))[1]
        filepath <- file.path("/var/www/Rcloud/upload", taskid)
        p<-paste("Your current task id: ", taskid, "<br>")
        cat(p)
        }
        %>
        <p>
        Or, you can change to other task by task id:<br>
        <form action="#" method="GET">
            <input type="text" name="task" value="" />
            <input type="submit" value="submit" />
        </form>
        <%
        if(!is.null(GET)){
        taskid <- GET$task
	filepath <- file.path("/var/www/Rcloud/upload", taskid)
	dir.create(filepath)
        setCookie("task", taskid)
        p <- paste("Your task id has changed to", taskid, "<br>")
        cat(p)
        }
        %>
    </body>
</html>
